import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.util.Set;

public class ValidateUtil {

    public static void main(String[] args) {
        /*ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
        Validator validator = factory.getValidator();

        User user = new User();
        user.setName(null); // 故意设置为null以触发@NotNull验证
        user.setPassword("short"); // 故意设置为短于6位以触发@Size验证

        Set<ConstraintViolation<User>> violations = validator.validate(user, User.class);

        for (ConstraintViolation<User> violation : violations) {
            System.out.println(violation.getPropertyPath() + " " + violation.getMessage());
        }*/
    }
}
